import { createSSRApp } from 'vue';
import * as Pinia from 'pinia';
import { createPersistedState } from 'pinia-plugin-persistedstate'
import './uni.scss';
import tmui from './tmui';
import App from './App.vue';
import { config } from './config';

export function createApp() {
  const app = createSSRApp(App);
  const store = Pinia.createPinia();
  store.use(createPersistedState({
    storage: {
      getItem: uni.getStorageSync,
      setItem: uni.setStorageSync,
    },
  }));

  app.use(store);
  app.use(tmui, { ...config } as Tmui.tmuiConfig);

  return {
    app,
    Pinia,
  };
}
